package com.ziyun.pop.web.modules.mercharReport.controller;

import com.ziyun.pop.common.utils.FileUtil;
import com.ziyun.pop.common.utils.JsonUtils;
import com.ziyun.pop.common.utils.UserUtils;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreOutVO;
import com.ziyun.pop.modules.mercharReport.service.ReportStoreOutService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;



/**
 * 门店耗材出库表
 *
 * @author jiangli
 * @email 
 * @date 2018-10-20 16:09:07
 */
@RestController
@RequestMapping("mercharReport/storematerialout")
public class ReportStoreOutController {
    @Autowired
    private ReportStoreOutService reportStoreOutService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("mercharReport:storematerialout:list")
    public R list(@RequestParam Map<String, Object> params){
        params.put("sellerId",UserUtils.getCurentUser().getSellerId());
        return reportStoreOutService.list(params);
    }

    /**
     * excel 导出
     */
    @RequestMapping("/exportExcel")
    public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
        String data = request.getParameter("postData");
        Map<String, Object> params = JsonUtils.string2Map(data);
        params.put("supplierId", UserUtils.getCurentUser().getSellerId());
        // 查询列表数据
        List<ReportStoreOutVO> list = reportStoreOutService.exportExcel(params);
        FileUtil.exportExcel(list, "门店耗材出库表", "门店耗材出库表", ReportStoreOutVO.class, "门店耗材出库表.xls", response);
    }


}
